# vim: filetype=yaml sw=2
filename: '[% project %]-[% c("version") %]-[% c("var/build_id") %].tar.gz'
version: 6.4.0
var:
  container:
    use_container: 1
  glibc_version: 2.25
  linux_version: 4.10.1
  deps:
    - build-essential
    - libmpc-dev
    - hardening-wrapper
    - libc6-dev-i386
    - gawk
  setup: |
    [% c("var/setarch") -%]
    mkdir -p /var/tmp/dist
    tar -C /var/tmp/dist -xf $rootdir/[% c("compiler_tarfile") %]
    export PATH="/var/tmp/dist/gcc-cross/bin:$PATH"
    #export LD_LIBRARY_PATH=/var/tmp/dist/gcc-cross/lib

    # Config options for hardening-wrapper
    export DEB_BUILD_HARDENING=1
    export DEB_BUILD_HARDENING_STACKPROTECTOR=1
    export DEB_BUILD_HARDENING_FORTIFY=1
    export DEB_BUILD_HARDENING_FORMAT=1
    export DEB_BUILD_HARDENING_PIE=1

    # Make sure we use the hardening wrapper
    # Cross-compiling...
    # First do the filename-prefixed ones...
    pushd /var/tmp/dist/gcc-cross/bin
    cp /usr/bin/hardened-cc ./
    mv [% c('var/crosstarget') %]-gcc [% c('var/crosstarget') %]-gcc.real
    mv [% c('var/crosstarget') %]-c++ [% c('var/crosstarget') %]-c++.real
    mv [% c('var/crosstarget') %]-g++ [% c('var/crosstarget') %]-g++.real
    ln -sf hardened-cc [% c('var/crosstarget') %]-gcc
    ln -sf hardened-cc [% c('var/crosstarget') %]-c++
    ln -sf hardened-cc [% c('var/crosstarget') %]-g++
    popd
    # Then do the directory-prefixed ones...
    # Or not... since they're not there...?!
    #pushd /var/tmp/dist/gcc-cross/[% c('var/crosstarget') %]/bin
    #cp /usr/bin/hardened-cc ./
    #mv gcc gcc.real
    #mv c++ c++.real
    #mv g++ g++.real
    #ln -sf hardened-cc gcc
    #ln -sf hardened-cc c++
    #ln -sf hardened-cc g++
    #popd

targets:
  linux-arm:
    var:
      configure_opt: --disable-multilib --enable-languages=c,c++ --target=arm-linux-gnueabihf --with-arch=armv7-a --with-fpu=vfpv3-d16 --with-float=hard --with-mode=thumb
input_files:
  - project: container-image
  - URL: 'https://ftp.gnu.org/gnu/gcc/gcc-[% c("version") %]/gcc-[% c("version") %].tar.xz'
    sha256sum: 850bf21eafdfe5cd5f6827148184c08c4a0852a37ccf36ce69855334d2c914d4
  - name: binutils
    project: binutils
  - URL: 'https://ftp.gnu.org/gnu/glibc/glibc-[% c("var/glibc_version") %].tar.xz'
    sha256sum: 067bd9bb3390e79aa45911537d13c3721f1d9d3769931a30c2681bfee66f23a0
  - URL: 'https://www.kernel.org/pub/linux/kernel/v4.x/linux-[% c("var/linux_version") %].tar.xz'
    sha256sum: 6ca06bb5faf5f83600d7388bb623dae41df2a257de85ad5d1792e03302bc3543
